//
//  Sphere.hpp
//  RayTracer
//
//  Created by 俞云康 on 3/25/16.
//  Copyright © 2016 yushroom. All rights reserved.
//

#ifndef Sphere_hpp
#define Sphere_hpp

#include "Shape.hpp"

class Sphere : public Shape
{
public:
    float3  center;         // position
    float   radius_squared;
    float   radius;
    
    Sphere(const std::string& name,
           const std::shared_ptr<Transform>& transform,
           float radius);
    
    static shared_ptr<Shape> create(const Params& params);
    
    virtual bool intersect(const Ray& r, HitInfo* hit) const override;
    virtual bool intersect(const Ray& r) const override;
    
    bool intersect_t(const Ray& r, float* t) const;
    
    virtual float area() const override;
    
    virtual Position sample(const Sample& sample,
                         Normal* shape_normal) const override;
    
    virtual Position sample(const Position& p,
                         const Sample& sample,
                         Normal* shape_normal) const override;
    
    virtual float pdf(const Position& p,
                      const Direction& wi) const override;
};


#endif /* Sphere_hpp */
